import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Item {
    id: cornerBack_ManualProcess
    width: 1760
    height: 630

    Component.onCompleted: {
        Cpp_PLC.read_Corner_Process_Hold();
        Cpp_PLC.write_into_PLC_16_Hold(48,"2")
    }

    A_NumberKeyboard{
        id: cornerProcessKeyboard
        isDirectOverwrite: false
    }

    property real fontSize: Cpp_Language.CurrentLanguage === 1 ? 40 : Cpp_Language.CurrentLanguage === 2 ? 25 : Cpp_Language.CurrentLanguage === 3 ? 25 : 40

    Rectangle{
        anchors.fill: parent
        border.width: 1
        color: "transparent"

        // Text{
        //     anchors.centerIn: parent
        //     font.pixelSize: 30
        //     text: qsTr("角码加工界面")
        // }
    }

    Column{
        anchors.horizontalCenter: cornerBack_ManualProcess.horizontalCenter
        anchors.top: cornerBack_ManualProcess.top
        anchors.topMargin: 20
        spacing: 10


        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("原 料 长 度")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 230
                inputWidth: 300
                inputHeight: 80
                keyboard: cornerProcessKeyboard
                text: Cpp_PLC.Corner_MaterialLength

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(1276,value)
                }
            }


            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 600
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("最 短 料 长")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 830
                inputWidth: 300
                inputHeight: 80
                keyboard: cornerProcessKeyboard
                text: Cpp_PLC.Corner_MaterialLength_Min

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(1292,value)
                }
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("角 码 长 度")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 230
                inputWidth: 300
                inputHeight: 80
                keyboard: cornerProcessKeyboard
                text: Cpp_PLC.Corner_Length

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(1272,value)
                }
            }


            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 600
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("角 码 段 数")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 830
                inputWidth: 300
                inputHeight: 80
                keyboard: cornerProcessKeyboard
                text: Cpp_PLC.Corner_Cut_Segments

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_16_Hold(228,value)
                }
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("刀       补")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 230
                inputWidth: 300
                inputHeight: 80
                keyboard: cornerProcessKeyboard
                text: Cpp_PLC.Corner_Knife_Compensate

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(1274,value)
                }
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("当 前 段 数")
                }

            }

            Rectangle{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                width: 300
                height: 80
                border.width: 2
                radius: 5
                border.color: "white"
                color: "black"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    color: "white"
                    text: Cpp_PLC.Current_Corner_Segments
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 800
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: qsTr("清  空")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(106,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(106,false)
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("累 计 段 数")
                }

            }

            Rectangle{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                width: 300
                height: 80
                border.width: 3
                radius: 5
                border.color: "white"
                color: "black"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    color: "white"
                    text: Cpp_PLC.Worked_Corner_Segments
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 800
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: qsTr("清  空")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(107,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(107,false)
            }

        }

    }


    Rectangle{
        width: 1200
        height: 1
        color: "black"
        anchors.horizontalCenter: cornerBack_ManualProcess.horizontalCenter
        anchors.bottom: cornerBack_ManualProcess.bottom
        anchors.bottomMargin: 100
    }

    Rectangle{      // 角码加工 - 手动操作按钮
        anchors.horizontalCenter: cornerBack_ManualProcess.horizontalCenter
        anchors.bottom: cornerBack_ManualProcess.bottom
        anchors.bottomMargin: 10
        width: 1750
        height: 80
        color: "transparent"


        Row{
            anchors.centerIn: parent
            spacing: 30

            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("左 移")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(21,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(21,false)
            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("右 移")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(22,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(22,false)
            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("定 位")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(24,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(24,false)
            }
        }

    }

}
